package org.example.tlias.controller;


import lombok.extern.slf4j.Slf4j;
import org.example.tlias.pojo.Emp;
import org.example.tlias.pojo.LoginInfo;
import org.example.tlias.pojo.Result;
import org.example.tlias.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private EmpService empService;

    @PostMapping
    public Result login(@RequestBody Emp emp) {
        log.info("员工登录{}", emp);
        LoginInfo loginInfo = empService.login(emp);
        if (loginInfo == null) {
            return Result.error("用户名或密码错误");
        }
        else {
            return Result.success(loginInfo);
        }
    }
}







